package com.ry.controller;

import com.ry.pojo.Cart;
import com.ry.pojo.CartTotal;
import com.ry.pojo.Result;
import com.ry.servcie.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

@RestController
public class testController {

    @Autowired
    private Testindexitems testindexitems;

    @Autowired
    private TestSearch testSearch;

    @Autowired
    private TestCart testCart;

    @Autowired
    private TestAddress testAddress;

    @Autowired
    private TestOrder testOrder;

    @Autowired
    private TestItem testItem;

    @Autowired
    private TestShop testShop;

    @Autowired
    private TestUser testUser;

    @RequestMapping("/ruoyi/index/getbanners")
    public Result testbanner(){
        return new Result(testindexitems.getbanner());
    }
    @RequestMapping("/ruoyi/index/getitems")
    public Result testindexitems(){
        return new Result(testindexitems.getItems());
    }
    @RequestMapping("/ruoyi/search/getcats")
    public Result testSearchCats(){
        return new Result(testSearch.getCats());
    }
    @RequestMapping("/ruoyi/search/getitems")
    public Result testSearchItem(Integer catId,String title){
        System.out.println(catId);
        System.out.println(title);
        return new Result(testSearch.getSearchItems(catId,title));
    }
    @RequestMapping("/ruoyi/search/getshops")
    public Result testSearchShop(String shopName){
        System.out.println(shopName);
        return new Result(testSearch.getSearchShops(shopName));
    }
    @RequestMapping("/ruoyi/cart/getcarts")
    public Result testGetCart(){
        return new Result(testCart.getCart());
    }
    @RequestMapping("/ruoyi/address/getaddrlist")
    public Result testGetAddress(){
        return new Result(testAddress.getAddrList());
    }
    @RequestMapping("/ruoyi/cart/deletecart")
    public Result testDeleteCart(Long itemId,Integer sizeId){
        return new Result();
    }
    @RequestMapping("/ruoyi/cart/changenum")
    public Result testchangenum(Long itemId,Integer num,Integer sizeId) {
        System.out.println(itemId);
        System.out.println(num);
        System.out.println(sizeId);
        return new Result();
    }
    @RequestMapping("/ruoyi/cleanCart")
    public Result testcleanCart(){
        System.out.println("清除成功!");
        return new Result();
    }
    @RequestMapping("/ruoyi/order/getorderid")
    public Result testGetOrderId(){
        return new Result(new Random().nextInt(999999999));
    }
    @RequestMapping("/ruoyi/order/saveorder")
    public Result testSaveOrder(String total,String addrId){
        System.out.println(total);
        System.out.println(addrId);
        return new Result();
    }
    @RequestMapping("/ruoyi/address/saveaddress")
    public Result testsaveaddress(String addrName,String phone,String address){
        System.out.println(addrName);
        System.out.println(phone);
        System.out.println(address);
        return new Result();
    }
    @RequestMapping("/ruoyi/address/removeaddr")
    public Result testremove(Integer addrId){
        System.out.println(addrId);
        return new Result();
    }
    @RequestMapping("/ruoyi/order/payorder")
    public Result testpayorder(String orderId){
        System.out.println(orderId);
        return new Result();
    }
    @RequestMapping("/ruoyi/order/getorder")
    public Result testGetOrders(Integer status){
        System.out.println(status);
        return new Result(testOrder.getOrders(status));
    }
    @RequestMapping("/ruoyi/order/deleteorder")
    public Result testDelOrder(String orderId){
        System.out.println(orderId);
        return new Result();
    }
    @RequestMapping("/ruoyi/item/getitem")
    public Result testGetItem(Long itemId){
        System.out.println(itemId);
        return new Result(testItem.getitem(itemId));
    }
    @RequestMapping("/ruoyi/item/addcart")
    public Result testAddCart(Long itemId,Integer sizeId){
        System.out.println(itemId);
        System.out.println(sizeId);
        return new Result();
    }
    @RequestMapping("/ruoyi/shop/getcats")
    public Result testgetShopCats(){
        return new Result(testSearch.getCats());
    }
    @RequestMapping("/ruoyi/shop/getmsg")
    public Result testgetmsg(Long shopId){
        System.out.println(shopId);
        return new Result(testShop.getmsg(shopId));
    }
    @RequestMapping("/ruoyi/shop/getitems")
    public Result testgetitems(Long shopId,String title,Integer catId){
        System.out.println("shopId:"+shopId);
        System.out.println("title:"+title);
        System.out.println("catId:"+catId);
        return new Result(testindexitems.getItems());
    }
    @RequestMapping("/ruoyi/shop/ssoshopname")
    public Result testSSOShopName(String shopName){
        System.out.println(shopName);
        return new Result();
    }
    @RequestMapping("/ruoyi/shop/open-shop")
    public Result testopenshop(String shopName,String password,String logo){
        System.out.println(shopName);
        System.out.println(password);
        System.out.println(logo);
        return new Result();
    }
    @RequestMapping("/ruoyi/login")
    public Result testLogin(String username ,String password){
        System.out.println(username);
        System.out.println(password);
        return new Result();
    }
    @RequestMapping("/ruoyi/register/ssousername")
    public Result testssousername(String username){
        System.out.println(username);
        return new Result();
    }
    @RequestMapping("/ruoyi/register")
    public Result testregister(String username,String password,String phone){
        System.out.println(username);
        System.out.println(password);
        System.out.println(phone);
        return new Result();
    }

    @RequestMapping("/ruoyi/user/getuser")
    public Result testGetUser(){
        Long userId = 100l;
        return new Result(testUser.getUser(userId));
    }
    @RequestMapping("/ruoyi/user/updateuser")
    public Result testUpdateUser(String userImgUrl,String newpassword,String password,String email,String phone){
        System.out.println("userImgUrl:"+userImgUrl);
        System.out.println("newpassword:"+newpassword);
        System.out.println("password:"+password);
        System.out.println("email:"+email);
        System.out.println("phone:"+phone);
        return new Result();
    }
    @RequestMapping("/ruoyi/logout")
    public Result testlogout(){
        return new Result();
    }
}
